# random valid speed list

def isIn(target, list):
    if len(list) == 0:
        return False
    else:
        index = 0
        while index < len(list):
            if target == list[index]:
                return True
            index = index + 1
    return False


valid_good = ['A', 'B', 'L']

customer_file = input('Where is the customer file?')

all_customer = []
all_customer_line = []


def separated_line(param):
    """
    get each line detail
    :param param: customer file each line
    :return: line detail
    """
    bulky = []
    light = []
    average = []
    goods = param.split(",")
    for good in goods:
        if good[0].upper() == 'L':
            light.append(good[1:].replace("\n", ""))
        elif good[0].upper() == 'B':
            bulky.append(good[1:].replace("\n", ""))
        elif good[0].upper() == 'A':
            average.append(good[1:].replace("\n", ""))
    return dict(light=light, bulky=bulky, average=average)


with open(customer_file) as f:
    lines = f.readlines()
    for line in lines:
        all_customer_line.append(line.replace("\n", ""))
        all_customer.append(separated_line(line.replace("\n", "")))
f.close()

valid_index = []


def get_valid(all_customer_line):
    for index in range(len(all_customer_line)):
        customer = all_customer_line[index]
        goods = customer.split(",")
        all_first = []
        for good in goods:
            if not isIn(good[0].upper(), valid_good):
                all_first.append(index)
        if all_first:
            valid_index.append(index)


def caculate_total(customer):
    total = 0
    for item in customer['light']:
        total = total + int(item)

    for item in customer['average']:
        total = total + int(item)

    for item in customer['bulky']:
        total = total + int(item)
    return total


get_valid(all_customer_line)
print('There are %d valid  customers waiting for registers, these are:' % (len(valid_index)))

for index in range(len(all_customer)):
    customer = all_customer[index]
    if not isIn(index, valid_index):
        print('%d. %d light items   %d average items and %d bulky items, for a total value of $%d' % (
            index + 1, len(customer['light']), len(customer['average']),
            len(customer['bulky']), caculate_total(customer)))
    else:
        print('%d. has invalid item values listed in file ' % (index + 1))
